<?php

namespace app\company\controller\user_profile\userArchive\psychologicalCounseling;

use app\company\service\user_profile\userArchive\psychologicalCounseling\PsychologicalCounselingService;
use app\BaseController;
use app\common\Message;

class PsychologicalCounseling extends BaseController
{
    use Message;

    /**
     * 咨询预约概况
     * @return bool|string
     */
    public function getOverview(): bool|string
    {
        $param = $this->request->param();
        $param['unit_id'] = $this->userData['unit_id'];
        try {
            $PsychologicalCounseling = new PsychologicalCounselingService($this->app);
            if(!$PsychologicalCounseling->getOverview($param)) throw new \Exception($PsychologicalCounseling->getMessage());
            return success($PsychologicalCounseling->getResult(),$PsychologicalCounseling->getMessage());
        } catch (\Exception $e) {
            return error($e->getMessage(),$e->getCode(),[
                'line' => $e->getLine(),
                'file' => $e->getFile()
            ]);
        }
    }

    /**
     * 线上咨询记录
     * @return bool|string
     */
    public function getOnlineRecode(): bool|string
    {
        $param = $this->request->param();
        $param['unit_id'] = $this->userData['unit_id'];
        try {
            $PsychologicalCounseling = new PsychologicalCounselingService($this->app);
            if(!$PsychologicalCounseling->getOnlineRecode($param)) throw new \Exception($PsychologicalCounseling->getMessage());
            return success($PsychologicalCounseling->getResult(),$PsychologicalCounseling->getMessage());
        } catch (\Exception $e) {
            return error($e->getMessage(),$e->getCode(),[
                'line' => $e->getLine(),
                'file' => $e->getFile()
            ]);
        }
    }

    /**
     * 线下预约记录
     * @return bool|string
     */
    public function getOfflineRecode(): bool|string
    {
        $param = $this->request->param();
        $param['unit_id'] = $this->userData['unit_id'];
        try {
            $PsychologicalCounseling = new PsychologicalCounselingService($this->app);
            if(!$PsychologicalCounseling->getOfflineRecode($param)) throw new \Exception($PsychologicalCounseling->getMessage());
            return success($PsychologicalCounseling->getResult(),$PsychologicalCounseling->getMessage());
        } catch (\Exception $e) {
            return error($e->getMessage(),$e->getCode(),[
                'line' => $e->getLine(),
                'file' => $e->getFile()
            ]);
        }
    }
}